<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/mobile/include/taglib.jsp"%>
<html>
<head>
	<title>商品单位</title>
	<%@include file="/WEB-INF/views/mobile/include/head.jsp" %>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#number").focus();
			$("#inputForm").validate({
				//rules: {
				//	name: {remote: "${ctx}/ivm/product/unit/checkName?oldName="+encodeURIComponent('${productUnit.number}${productUnit.name}')+"&mId="+encodeURIComponent('${productUnit.merchant.id}')}
				//},
				messages: {
					name: {remote: "商品单位已存在,请重新输入."}
				},
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element.parent());
					}
				}
			});
		});
	</script>
</head>
<body data-role="page">
	<div data-role="header" class="ui-header" data-position="fixed" data-tap-toggle="false">
		<div data-role="controlgroup" data-type="horizontal" class="ui-btn-left">
			<a href="${ctx }/ivm/product/unit"><img class="head-back-icon" src="${ctxFront}/images/head/android/back.png"/></a>
	    </div>
	    <h1>商品单位</h1>
	    <div data-role="controlgroup" data-type="horizontal" class="ui-mini ui-btn-right">
	        <a href="javascript:" onclick="$('#inputForm').submit()" class="float-right"><img class="head-save-icon" src="${ctxFront}/images/head/android/save.png"/></a>
	    </div>
	</div>
	<div role="main" class="ui-content">
		<form:form id="inputForm" modelAttribute="productUnit" action="${ctx}/ivm/product/unit/save" method="post" class="form-horizontal">
			<form:hidden path="id"/>
			<form:hidden path="merchant.id"/>
			<tags:mbmessage content="${message}"/>
			<div data-role="fieldcontain">
		          <label for="name">名称:</label>
					<input id="oldName" name="oldName" type="hidden" value="${productUnit.number}${productUnit.name}">
				  <div class="unit-input-small">
				  	<input type="text" id="number" name="number" maxlength="200" class="required digits" value="${productUnit.number }"/>
					<input type="text" id="name" name="name" maxlength="200" class="required" value="${productUnit.name}"/>
				  </div>
			</div>
			<div data-role="fieldcontain">
		          <label for="sort">排序:</label>
					<form:input path="sort" htmlEscape="false" maxlength="50" class="required digits"/>
			</div>
			<div data-role="fieldcontain">
		          <label for="remarks">备注:</label>
					<form:textarea path="remarks" htmlEscape="false" maxlength="200" class="input-xxlarge"/>
			</div>
		</form:form>
	</div>
	<%@include file="/WEB-INF/views/mobile/layouts/menu.jsp" %>
</body>
</html>
